function plotspread( a, b, HP, gmm, X, Y )

close all;

v = squeeze(HP(a,b,1:61));
lamda = sqrt(v'*v);
v = v / sqrt(v'*v);

w = randn(61,1);
w = w - w'*v*v;
w = w / sqrt(w'*w);

A = [v, w];

c = HP(a,b,62)/lamda;

scatter( X(Y==a,:)*v  + c,X(Y==a,:)*w,'x','r');
hold on;
scatter( X(Y==b,:)*v + c,X(Y==b,:)*w,'+','b');

ylim = get(gca, 'YLim');
plot([0, 0],[ylim(1) ylim(2)], 'k', 'LineWidth', 2)

num_components = size(gmm.model{a}.mu, 1);
mua = cell(num_components, 1);
mub = cell(num_components, 1);
sigmaa = cell(num_components, 1);
sigmab = cell(num_components, 1);

for k = 1 : num_components
    mua{k} = [gmm.model{a}.mu{k}' * v + c; gmm.model{a}.mu{k}' * w];
    mub{k} = [gmm.model{b}.mu{k}' * v + c; gmm.model{b}.mu{k}' * w];
    sigmaa{k} = A' * gmm.model{a}.sigma{k} * A;
    sigmab{k} = A' * gmm.model{b}.sigma{k} * A;
end

for k = 1 : num_components
    plot_gauss_2d(mua{k}, sigmaa{k}, 1, 'g');
    plot_gauss_2d(mub{k}, sigmab{k}, 1, 'g');
end

end

